package edu.nf.redismqes.service.handler;

import edu.nf.redismqes.model.docmentt.NewDoc;
import edu.nf.redismqes.model.entity.New;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @ Author bin
 * @ Create  2025/10/22 上午10:54
 **/
@Service
@Transactional
public class DelNewHandler implements NewHandler{
    @Autowired
    private edu.nf.redismqes.mappers.newsMapper newsMapper;

    /**
     * 注入ElasticsearchOperations
     */
    @Autowired
    private ElasticsearchOperations operations;

    @Override
    public String getAction() {
        return "delNews";
    }

    @Override
    public void handle(New news) {
        newsMapper.delete(news.getId());

        operations.delete(news.getId().toString(), NewDoc.class);
    }
}
